/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fpt.session;

import edu.fpt.entity.Customer;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author TuanAnh
 */
@Stateless
public class CustomerFacade extends AbstractFacade<Customer> implements CustomerFacadeLocal {

    @PersistenceContext(unitName = "ProjectManagementHotel-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CustomerFacade() {
        super(Customer.class);
    }

    @Override
    public boolean checkPass(String id) {
        boolean flag = true;
        try {
            List<Customer> list = findAll();
            for (Customer cus : list) {
                if (id.equals(cus.getPasspost())) {
                    flag = false;
                }
            }
        } catch (Exception ex) {
        }
        return flag;
    }
}
